from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

import default_config
from common.crawlUtil import crawl
from common.db import UrlList
from common.utilFunction import calculate
from resources.proxy import get_proxy

engine = create_engine("mysql+pymysql://root:" + default_config.MYSQL_PASSWORD + "@localhost:3306/tandi?charset=utf8")
Session = sessionmaker(bind=engine)
session = Session()

get_proxy(session)

urlLists = session.query(UrlList).all()
crawl(urlLists)
calculate()
